<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1                                                                .0">
    <title>05-浅拷贝</title>
</head>
<body>
    <script>
        // 浅拷贝只是一层，更深层次对象级别的拷贝引用
        // 深拷贝拷贝多层，每一级别的数据都会拷贝
        let obj = {
            id:1,
            name:"andy",
            msg:{
                age:18,
            }
        };
        let target = {};

        // 浅拷贝 原生 js
        for(var k in obj){
            console.log(k + "-" +obj[k]);
            target[k] = obj[k];
        }

        // 浅拷贝 
        Object.assign(target,obj);
        
        obj.id=2;
        console.log(obj);
        console.log(target);

        console.log(target);
        target.msg.age = 99;
        console.log(obj);
    </script>
</body>
</html>